<template>
	<view>
		<view class="topview">
			<!-- 		<u-search searchIconSize="35" :showAction="true" placeholder="请输入罐式集装箱信息" actionText="搜索" :animation="true">
			</u-search> -->
			<u-tabs :list="list1" @click="tabClick" :current="current" @change="tabChange" lineWidth="63px"
				lineColor="#1590EF" :activeStyle="{
					    color: '#1590EF',
					    fontWeight: 'bold',
					    transform: 'scale(1.05)'
					}" :inactiveStyle="{
					    color: '#606266',
					    transform: 'scale(1)'
					}" itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;"></u-tabs>
		</view>

		<view style="padding-bottom: 20px;" v-if="current==1">
			<!-- 基本信息 -->
			<view class="list_item">
				<view class="item_top">
					<view class="view_pai">
						<u-image :src="src1" width="10px" height="12px" style="margin-right: 5px;"></u-image>
						<text class="text_pai">基本信息</text>
					</view>
				</view>
				<view style="height: 1px;background-color: #ccc;"></view>
				<view class="item_bottom">
					<view class="bottom_text">
						<view class="text_left">罐车号牌</view>
						<view class="text_right">{{mapData.vehCode}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">车牌颜色</view>
						<view class="text_right">{{mapData.vehColor}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">营运状态</view>
						<view class="text_right">{{findState(mapData.ccerState)}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">所属企业</view>
						<view class="text_right">{{mapData.ownerName}}</view>
					</view>
				</view>
			</view>




			<view class="list_item" v-for="(item,index) in listData" :key="index">
				<view class="item_top">
					<view class="view_pai">
						<u-image :src="src1" width="10px" height="12px" style="margin-right: 5px;"></u-image>
						<text class="text_pai">定期检验信息</text>
					</view>
				</view>
				<view style="height: 1px;background-color: #ccc;"></view>
				<view class="item_bottom">
					<view class="bottom_text">
						<view class="text_left">检验机构</view>
						<view class="text_right">{{item.testMechanism}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">检验日期</view>
						<view class="text_right">{{item.testDate}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">有效期止</view>
						<view class="text_right">{{item.termOfValidityStop}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">检验报告</view>
						<view class="text_right"><a @click="handleFile(item.testReportRoute)">查看检验报告</a></view>
					</view>
				</view>
			</view>



		</view>

		<!-- 企业信息 -->
		<view style="padding-bottom: 20px;" v-if="current==0">
			<!-- 基本信息 -->
			<view class="list_item">
				<view class="item_top">
					<view class="view_pai">
						<u-image :src="src1" width="10px" height="12px" style="margin-right: 5px;"></u-image>
						<text class="text_pai">基本信息</text>
					</view>
				</view>

				<view style="height: 1px;background-color: #ccc;"></view>
				<view class="item_bottom">
					<view class="bottom_text">
						<view class="text_left">罐车号牌</view>
						<view class="text_right">{{mapData.vehCode}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">车牌颜色</view>
						<view class="text_right">{{mapData.vehColor}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">营运状态</view>
						<view class="text_right">{{findState(mapData.ccerState)}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">所属企业</view>
						<view class="text_right">{{mapData.ownerName}}</view>
					</view>
				</view>
			</view>

			<view class="list_item">
				<view class="item_top">
					<view class="view_pai">
						<u-image :src="src1" width="10px" height="12px" style="margin-right: 5px;"></u-image>
						<text class="text_pai">道路运输证信息</text>
					</view>
				</view>
				<view style="height: 1px;background-color: #ccc;"></view>
				<view class="item_bottom">
					<view class="bottom_text">
						<view class="text_left">道路运输证号</view>
						<view class="text_right">{{mapData.ccertId}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">有效期起</view>
						<view class="text_right">{{mapData.firstDate}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">有效期止</view>
						<view class="text_right">{{mapData.expireDate}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">经营范围</view>
						<view class="text_right">{{mapData.mgrArea}}</view>
					</view>
				</view>
			</view>


			<view class="list_item">
				<view class="item_top">
					<view class="view_pai">
						<u-image :src="src1" width="10px" height="12px" style="margin-right: 5px;"></u-image>
						<text class="text_pai">罐箱详情</text>
					</view>
				</view>
				<view style="height: 1px;background-color: #ccc;"></view>
				<view class="item_bottom">
					<view class="bottom_text">
						<view class="text_left">制造厂编号</view>
						<view class="text_right">{{mapData.canTankDeliveryNumber}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">制造日期</view>
						<view class="text_right">{{mapData.dateOfProduction}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">集装箱代码（ISO）</view>
						<view class="text_right">{{mapData.containerCode}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">UN罐柜导则</view>
						<view class="text_right">{{mapData.unTankGuide}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">空箱质量</view>
						<view class="text_right">{{mapData.tareMass}}</view>
					</view>
					<!-- <view class="bottom_text">
						<view class="text_left">最大营运质量</view>
						<view class="text_right">{{mapData.maximumLoadMass}}</view>
					</view> -->
					<view class="bottom_text">
						<view class="text_left">最大载质量</view>
						<view class="text_right">{{mapData.maximumLoadMass}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">容积</view>
						<view class="text_right">{{mapData.volume}}</view>
					</view>
					<view class="bottom_text">
						<view class="text_left">性能参数</view>
						<view class="text_right">{{mapData.performanceParameter}}</view>
					</view>
				</view>
			</view>

		</view>


	</view>
</template>

<script>
	import {
		maCode
	} from '@/common/api/req.js'
	export default {
		data() {
			return {
				src1: "/static/index/tj_icon.png",
				list1: [{
					name: '罐式集装箱信息',
				}, {
					name: '定期检验信息',
				}],
				current: 0,
				mapData: {},
				listData: [],
				array: [],
				datumPath: ""
			};
		},
		onLoad(option) {
			this.mapData = JSON.parse(option.data)
			this.listData = JSON.parse(option.data).insp
		},
		mounted() {
			maCode('file_domain_intranet').then(res => {
				this.datumPath = res.data.data[0].dictValue
			})
			//营运状态
			maCode('ccert_state').then(res => {
				let list = res.data.data
				this.array = list.map(item => {
					return {
						dictValue: item.dictValue,
						dictKey: item.dictKey
					}
				})
			})
		},
		methods: {
			handleFile(url = '') {
				if (url && !url.startsWith('http')) {
					if (url.indexOf("staticAnnex")==-1) {
						url = this.datumPath + url;
					} else {
						url = this.datumPath.substring(0, this.datumPath.length - 9) + url;
					}
				}
				this.$goBack('../preview/index?url=' + url)
			},
			tabClick() {},
			tabChange(e) {
				this.current = e.index
			},
			findState(state) {
				let data = this.array.find((item) => {
					return item.dictKey == state
				})
				if (data) {
					return data.dictValue
				}

			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #EFEFEF;
	}

	.topview {
		padding: 0px 15px;
		background-color: #fff;
		position: sticky;
		z-index: 999;
		top: 0;


		.u-search__content {
			padding: 5px 10px;
		}
	}


	.list_item {
		border-radius: 10px;
		background-color: #FFFFFF;
		margin: 10px 20px 0 20px;
		padding-bottom: 5px;



		.item_top {
			display: flex;
			justify-content: space-between;
			height: 80rpx;
			border-radius: 10rpx;

			.view_pai {
				padding-left: 30rpx;
				height: 40rpx;
				margin-top: 30rpx;
				display: flex;
				align-items: center;

				.text_pai {
					font-size: 28rpx;
					font-weight: 700;
				}
			}

			.view_state {
				height: 50rpx;
				border-top-right-radius: 10rpx;
				border-bottom-left-radius: 8rpx;
				padding-left: 5rpx;
				padding-right: 5rpx;
				background-color: #666666;
				display: flex;
				align-items: center;

				.text_state {
					font-size: 28rpx;
					font-weight: 700;
				}
			}

		}

		.item_line {
			height: 1rpx;
			background-color: #F2F2F2;
			margin-left: 35rpx;
			margin-right: 35rpx;
		}

		.item_center {
			display: flex;
			flex-direction: column;
			padding-left: 35rpx;
			padding-top: 20rpx;
			padding-bottom: 10rpx;

			.center_top {
				display: flex;
				height: 50rpx;
				align-items: center;

				.view_jia {
					width: 45rpx;
					height: 45rpx;
					background-color: #4CAF50;
					border-radius: 45rpx;
					display: flex;
					justify-content: center;
					align-items: center;

					text {
						color: #FFFFFF;
						font-size: 20rpx;
						font-weight: 700;
					}
				}

				.view_ya {
					width: 45rpx;
					height: 45rpx;
					background-color: #2196F3;
					border-radius: 45rpx;
					display: flex;
					justify-content: center;
					align-items: center;

					text {
						color: #FFFFFF;
						font-size: 20rpx;
						font-weight: 700;
					}
				}

				.text_name {
					margin-left: 20rpx;
					font-size: 28rpx;
					font-weight: 700;
				}

				.text_phone {
					margin-left: 30rpx;
					font-size: 28rpx;
					font-weight: 700;
					color: #666666;
				}
			}

			.center_line {
				margin-left: 22rpx;
				height: 15rpx;
				width: 5rpx;
				background-color: #000000;
			}

		}

		.item_bottom {
			display: flex;
			flex-direction: column;
			padding-left: 35rpx;
			padding-top: 10px;

			.bottom_text {
				display: flex;
				align-items: center;
				padding-top: 10rpx;
				padding-bottom: 10rpx;

				.text_left {
					font-size: 30rpx;
					color: #666666;
					width: 120px;
				}

				.text_right {
					flex: 1;
					font-size: 30rpx;
					display: inline-block;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
				}

			}
		}
	}

	.view_name {
		// width: calc(100% - 40px);
		height: 90px;
		display: flex;
		padding: 10px;
		background-color: #fff;
		margin: 10px 20px;
		border-radius: 10px;

		.left_name {
			flex: 2;
			background-color: aqua;
			display: flex;
			align-items: center;

			text {
				color: #1590EF;
				font-size: 20px;
				margin-left: 15px;
			}
		}

		.right_code {
			flex: 1;
			background-color: aquamarine;
		}

	}
</style>
